﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace 充电桩上位机.Model.Checked;

public class UserCheck : CheckBox
{
    public static readonly DependencyProperty StatusProperty =
        DependencyProperty.Register(
            nameof(Status),
            typeof(bool),
            typeof(UserCheck),
            new PropertyMetadata(false, OnStatusChanged));
    public bool Status
    {
        get => (bool)GetValue(StatusProperty);
        set => SetValue(StatusProperty, value);
    }
    private static void OnStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is UserCheck button)
        {
            button.UpdateBackground();
        }
    }

    private void UpdateBackground()
    {
        //Background = Status ? Brushes.Black : Brushes.White;
        Foreground = Status ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2563EB")) : Brushes.Black;
    }
}
